\fi-400\li400 Q: I am writing an app where I read and write TIFF files. When I open a TIFF file I would like to know what kind of compression may have been used on that image so I can save it out with the same format. How can I do this?\
\i\fi0\li0 \
\i0\fi-400\li400 A: There is no NXBitmapImageRep method that will allow you to do this. However there is a 1.0 routine (still supported in 2.0) called
\f3\fs24 NXGetTIFFInfo()
\f0\fs28 which will return information about a TIFF file. In general, we do not recommend that you use
\f3\fs24 NXGetTIFFInfo()
\f0\fs28 for anything other than looking at compression information or how many images a TIFF file may contain. The NXBitmapImageRep class in 2.0 is the recommended manner for managing TIFF files.\
\
\fi0 Here is a code sample which uses NXGetTIFFInfo to examine the file 'fileName' (probably returned from the OpenPanel). Also a couple things to note:\
\
\fi-180\li580\fc0 • The count returned represents the number of bytes when the image is uncompressed. There is no way to determine how many compressed bytes the image consumes. \
\
• In this example the imageNumber has been hardcoded to zero. It is possible to store more than one image in a TIFF file. After you've received the NXTIFFInfo structure for the first image you can look at the info.numImages field to see if there are other images there that you may wish to peruse. For example some application icons have two images in the same TIFF file -- one 2-bit image for B&W monitors, one 16-bit image for color monitors. The appkit extracts the appropriate image.\
\
• There is no way to determine which compression factor was used for a JPEG image.\
\b0 command-line utility in 2.0 also provides a quick way to extract information about a TIFF file in a Terminal window. There is a man page on tiffutil.\